<? session_start();
						
include_once ('core/conn.php');
						
$db = get_conn();
						
check_session();
						
if($_GET['id'] != ''){
							
	$sql = " select * from assets where id_asset=".$_GET['id']; 
							
	$result = mysql_query($sql);	
							
	if($result){
								
		$row = mysql_fetch_array($result);
		$id_asset = $row['id_asset'];
		$id_facility = $row['id_facility'];
		$name = $row['name'];
		$astatus = $row['astatus'];
		$restrictions = $row['restrictions'];
							
	}else{
								
		error_handling($sql,mysql_error());
							
	}
						
}
						
						
					
?>
					
					
<html>
					
<head>
					
					

				
				
<script>
					
<!--
						
	function checkdata(obj){
							
						
							
		if(obj.id_facility.value ==''){
								
			alert('Please select the facility');
								
			obj.id_facility.focus();
								
			return false;
							
		}
							
			
						
							
		if(obj.name.value ==''){
								
			alert('Please fill the name');
								
			obj.name.focus();
								
			return false;
							
		}
							

							
		if(obj.restrictions.value ==''){
								
			alert('Please fill the restrictions');
								
			obj.restrictions.focus();
								
			return false;
							
		}
	return true;
						
	}
					
-->
					
</script>
					
</head>									
					
<body>														
				
				
<form name='assets' method='post' action='/core/assets.php' onsubmit='return checkdata(this)'>
  <table width='100%' border='0'>
    <tr>
      <td align='left'> Facility </td>
      <td align='left'><? 
			
			$extraitems = "<option value=''>Seleccione</option>";
			$sql="select id_facility as myvalue, concat(ft.name ,' ', f.name) as mydesc  
					from facilities f , `facility_type` ft 
					where f.id_ftype = ft.id_ftype";
				echo dbcombosql($sql,"id_facility",$id_facility,$javascript,$extraitems);				
				
				
			?>
      <input type='hidden' name='id_asset' value='<? echo $id_asset;?>'></td>
    </tr>
    <tr>
      <td align='left'> Name </td>
      <td align='left'><input name='name' type='text' value='<? echo $name;?>' size="40"></td>
    </tr>
    <tr>
      <td align='left'> Status </td>
      <td align='left'><select name="astatus" class="contenido_forma">
        <option value="A" <? echo getStatus($astatus,"A")?>>Active</option>
        <option value="I" <? echo getStatus($astatus,"I")?>>Inactive</option>
      </select></td>
    </tr>
    <tr>
      <td align='left'> Restrictions </td>
      <td align='left'><textarea name="restrictions" cols="40" rows="6"><? echo $restrictions;?></textarea></td>
    </tr>
    <tr>
      <td colspan='2' align='center'><?
							  
					if ($_GET['id'] != ""){
								
						echo "<input type='submit' name='Actualizar' value='Actualizar'>";
								
						echo "<input type='submit' name='Eliminar' value='Borrar'>";										
								
						echo "<input type='submit' name='Nuevo' value='Cancelar'>";
							  
					}else{
								
						echo "<input type='submit' name='Agregar' value='Agregar'>";
							  
					}
							 
					?></td>
    </tr>
  </table>
</form>
					
</body></html>													
					